package com.example.litterpainterdemo.draw.shapes

import android.graphics.Canvas
import android.util.Log

class RectangleShape:Shape() {
    var left = 0f
    var right = 0f
    var top = 0f
    var bottom = 0f
    override fun insideTheShape(dx:Float,dy:Float):Boolean{
        return (dx in left..right && dy in top..bottom)
    }

    override fun drawShape(canvas: Canvas?) {
        left = Math.min(startPoint.x,endPoint.x)
        right = Math.max(startPoint.x,endPoint.x)
        top = Math.min(startPoint.y,endPoint.y)
        bottom = Math.max(startPoint.y,endPoint.y)
        canvas?.drawRect(left,top,right,bottom,mPaint)
    }
}

